class Solution:
    def merge(self, nums1: List[int], m: int, nums2: List[int], n: int) -> None:
        """
        Do not return anything, modify nums1 in-place instead.
        """
        if m == 0:
            for i in range(n):
                nums1[i] = nums2[i]
        elif n == 0:
            pass
        else:
            j = 0
            insert = 0
            flag = False
            for i in range(m):  
                if flag:
                    break
                while nums1[i + insert] >= nums2[j]: 
                    nums1.insert(i+ insert, nums2[j])
                    nums1.pop()
                    insert += 1
                    j += 1
                    if j == n or (i + insert) == m + n:
                        flag = True
                        break
            for i in range(n - j):
                nums1[i+m+insert] = nums2[j+i]